/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.teste;

import br.com.modelo.Editora;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author egberto
 */
public class ListaEditorasComJPA {
    
    public static void main(String args[]){
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("default");
        EntityManager manager = factory.createEntityManager();
        
        Query query = manager.createQuery("SELECT e FROM Editora e");
        
        List<Editora> editoras = query.getResultList();
        
        for (Editora e : editoras) {
            System.out.println("Editora: " + e.getNome() + " - " + e.getEmail());
        }
        
        factory.close();
    }
    
}
